(1) Field of the Invention
The present invention relates to a method for storing floating point numbers so as to make it easier to manage the floating point numbers using a fixed point processor, and an arithmetic device for the floating point numbers.
(2) Description of the Prior Art
As a typical example of a conventional format for storing floating point numbers (numbers represented in a floating point format), there is a 32-bit floating point number format in conformity with the IEEE 754 standard. Variables which are declared in a floating point mode in C language conform to this format.
FIG. 1 is a diagram showing a bit field of the 32-bit floating point format in conformity with the IEEE 754 standard. In this figure, the most significant 1 bit is a sign bit storage field 70, which indicates a positive number for 0 and a negative number for 1.
The 8-bit field following the sign bit is called an exponent storage field 71. The 23-bit field following the exponent is called a mantissa storage field 72. When the 8-bit exponent represents a value e of an integer and the 23-bit mantissa represents a value k of a fixed point number (a number represented in a fixed point format) with its binary point being placed immediately to the left of the most significant bit (MSB) of this 23-bit mantissa, a real number x is represented in this floating point format as:x=(2^(e−127))*(1·k)
Here, the representation of (1·k) indicates that a binary point is placed immediately to the left of the MSB of the 23-bit data k and the implicit bit immediately to the left of the binary point is always “1”. For example, when the 23-bit data k is
k=10000000000000000000000
represents(1·k)=b′1.10000000000000000000000=1+0.5=1.5.For another example,
k=11100000000000000000000
represents(1·k)=b′1.11100000000000000000000=1+0.5+0.25+0.125 1.875.The mantissa is a field for representing values of 1 or more but less than 2.
According to the above examples, when a bit pattern represented in the 32-bit floating point format in conformity with the IEEE 754 standard indicates, for instance,
0 10000000 11100000000000000000000,
the real number value x indicated by this bit pattern isx=(2^(128−127))*1.875=3.75.
Also, in the case of
0 01111110 10000000000000000000000,
the real number value x indicated by this bit pattern isx=(2^(126−127))*1.5=0.75.In the 32-bit floating point format in conformity with the IEEE 754 standard, a mantissa a and an exponent n in the case of x=a*2^n are converted as mentioned above so as to represent a real number x. Therefore, real numbers in a wide range from −2^129˜2^129 can be represented.
On the other hand, there is a fixed point number format as a number format which does not require such a complicated conversion. As shown in FIGS. 2A and 2B, this is a number format without the above-mentioned exponent storage field, where the MSB is usually sign data and a binary point is fixed at a predetermined bit place in the following bits. For example, as shown in FIG. 2A, when a binary point is placed just below the sign bit, the range of represented numbers is limited to −1˜+1. For example,
0 1000000000000000000000000000000
represents 0.5 because the MSB is 0, a positive number, and the first bit after the binary point indicates 1. For another example,
0 1100000000000000000000000000000
represents 0.75 (0.5+0.25) because the MSB is 0, a positive number, and the first and second bits after the binary point indicate 1. Positive and negative numbers are usually represented by two's complements, and, for example,
1 0000000000000000000000000000000
represents −1. And,
1 1100000000000000000000000000000
represents −0.25.
If a number unmanageable within the limit of −1˜+1 is processed, the binary point is fixedly placed at 2-bit right of the MSB, for example, as shown in FIG. 2B.
For example,
01 010000000000000000000000000000
represents 1.25 because the MSB is 0, a positive number, the bit immediately to the left of the binary point is 1, and the second bit after the binary point is 1.
As described above, as represented by IEEE754, floating point numbers are conventionally represented by a format in which a sign bit, an exponent and a mantissa are stored from the higher order. On the other hand, fixed point numbers are represented by a format in which a sign bit and numbers are stored from the higher order.
However, in the above-mentioned floating point number storage format, in order to extract only the value of the exponent, the most significant 1 bit and the lower 23 bits need to be separated from the 32-bit data, which requires an enormous amount of processing. This is a problem.
On the other hand, in order to extract only the value of the mantissa, the above-mentioned processing of (1·k) needs to be performed after only the value of the lower 23 bits is extracted, which also requires an enormous amount of processing.
In addition, when real numbers x and y which are stored in the above-mentioned floating point format is multiplied,x*y=(a*2^n)*(b*2^m)=a*b*2^(n+m)is given, where x=a*2^n and y=b*2^m. Therefore, the multiplication of the mantissas of the bit fields for x and Y, and the addition of the exponents thereof need to be performed, and thus the exponents and the mantissas need to be separated from the respective bit fields for every multiplication. This processing requires an enormous amount of processing.
On the other hand, in the above-mentioned fixed point number storage format, although the processing amount is less than that in the floating point format because there is no need to separate the exponents and the mantissas for arithmetic, there is a problem that the range of representable numbers are limited.